import 'package:bloctest/utils/base/BasePresenter.dart';
import 'package:bloctest/utils/http/dio_instance.dart';

import '../../model/knowledge_model.dart';
import 'knowledge_page.dart';
import 'package:dio/dio.dart';
class KnowledgePresenter extends BasePresenter<KnowledgePageState>{
  
  KnowledgePresenter(super.state);
  
  @override
  Future<void> loadData(Map<String, dynamic> loadDataParams) async {
    // TODO: implement loadData
    await getKnowledgeList();
    state?.notify();

    return super.loadData(loadDataParams);
  }
  
  
  Future<void> getKnowledgeList() async{
    Response response=await DioInstance.instance().doGet("tree/json", null);
    var model= KnowledgeModel.fromJson(response.data);
    if (model.knowledgeList != null) {
      state?.knowledgeList = model.knowledgeList!;
    } else {
      state?.knowledgeList = [];
    }
  }
}